import logging,logging.handlers
import os.path
BaseDir=os.path.dirname(__file__)
def init_logging():
    logger=logging.getLogger()
    logger.setLevel(logging.DEBUG)
    fh=logging.handlers.TimedRotatingFileHandler(BaseDir+"/log/log.log",
                                                 when='midnight',interval=1,backupCount=7)
    sh=logging.StreamHandler()
    fh.setLevel(logging.INFO)
    sh.setLevel(logging.INFO)
    fmt="%(asctime)s %(levelname)s [%(name)s]" \
        "[%(filename)s(%(funName)s:%(lineno)d]- %(message)s"
    formatter=logging.Formatter(fmt=fmt)
    fh.setFormatter(formatter)
    sh.setFormatter(formatter)
    logger.addHandler(fh)
    logger.addHandler(sh)